package com.project.service;

import com.project.dao.PositionTypeMapper;
import com.project.dao.SysInfoMapper;
import com.project.entity.PositionType;
import com.project.entity.SysInfo;
import com.project.service.base.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by hasee on 2017/4/28.
 */
@Transactional(rollbackFor=Exception.class)
@Service
public class SysInfoServiceImpl extends BaseService implements SysInfoService {
    private static SysInfoMapper sysInfoMapper = null;
    public void setMapper()
    {
        if(sysInfoMapper==null)
            sysInfoMapper = sqlSessionTemplate.getMapper(SysInfoMapper.class);//1.获取相关mapper
    }
    @Override
    public SysInfo findById(int id) {
        setMapper();
        return sysInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int update(SysInfo sysInfo) {
        setMapper();
        return sysInfoMapper.updateByPrimaryKeySelective(sysInfo);
    }

    @Override
    public int creat(SysInfo sysInfo) {
        setMapper();
        return sysInfoMapper.insertSelective(sysInfo);
    }

    @Override
    public int delete(int id) {
        setMapper();
        return sysInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<SysInfo> findall() {
        setMapper();
        return sysInfoMapper.selectAll();
    }
}
